/**
 * Project Name:HomeActivity
 * Date:2016-7-4下午3:31:28
 * Copyright (c) 2016, askzhao All Rights Reserved.
 *
 */
package com.kkd.kkdapp.adapter;

import java.util.ArrayList;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.activity.LivePlayerActivity;
import com.kkd.kkdapp.utils.SystemUtils;
import com.kkd.kkdapp.view.RoundImageView;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * ClassName: QuickEntryAdapter <br/>
 * date: 2016-7-4 下午3:31:28 <br/>
 * 
 * @author askzhao
 * @version
 */
public class LiveLikerHeadAdapter extends
		RecyclerView.Adapter<LiveLikerHeadAdapter.MyViewHolder> {

	private Context mContext;
	private ArrayList<String> mData;
	private LayoutInflater mInflater;
	private int mLikerCount = 0;
//	private int max=5;

	/**
	 * @param mCurActivity
	 * @param mQuickIn
	 */
	public LiveLikerHeadAdapter(Context context, ArrayList<String> list,int like_count) {
		mContext = context;
		mData = list;
		mInflater = LayoutInflater.from(context);
		mLikerCount = like_count;
		
	}

	public class MyViewHolder extends ViewHolder {
		RoundImageView head_img;

		public MyViewHolder(View view) {
			super(view);
			head_img = (RoundImageView) view.findViewById(R.id.head_img);
		}
	}

	@Override
	public int getItemCount() {
		if(mData.size()>getMax()){
			return getMax()+1;	
		}else{
			return mData.size();	
		}
		
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public void onBindViewHolder(MyViewHolder nViewHolder, final int position) {
		if(position<getMax()){
			ImageLoader.getInstance().displayImage(
					mData.get(position), nViewHolder.head_img);
		}else if(position==getMax()){
			nViewHolder.head_img.setImageResource(R.drawable.live_ellipsis);
		}
		
	}

	@Override
	public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		MyViewHolder holder = new MyViewHolder(mInflater.inflate(
				R.layout.live_liker_head_item, parent, false));
		return holder;
	}
	
	public void setMax(int max){
//		this.max = max;
	}
	
//	public void fliperListLiker() {
//		if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
//			int max = (SystemUtils.getScreenWidth(this) - SystemUtils.dip2px(
//					LivePlayerActivity.this, 110))
//					/ SystemUtils.dip2px(LivePlayerActivity.this, 38) - 3;
//			if (max <= 0)
//				return;
//			mLiveLikerHeadAdapter.setMax(max);
//			if (list_liker.size() > max) {
//				for (int i = 0; i < list_liker.size() - max; i++) {
//					list_liker.remove(i + max);
//				}
//			}
//		}
//
//	}
	
	private int getMax(){
		int max = (SystemUtils.getScreenWidth(mContext) - SystemUtils.dip2px(
				mContext, 95))	/ SystemUtils.dip2px(mContext, 38)-1;
		return max;
	}
}